package design._02_观察者;

import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.IOException;

public class _0711_Swing {
    public static void main(String[] args) throws IOException {
        _0711_Swing sw2 = new _0711_Swing();
        sw2.go();
        System.in.read();
        _0711_WeatherData data = new _0711_WeatherData();
        //data.setChanged();
    }
    public void go(){
        JFrame frame = new JFrame();
        JButton btn = new JButton("Should I do It?");
        btn.addActionListener(new AngelListener());
        btn.addActionListener(new DevilListener());

        // 哦金
        frame.getContentPane().add(BorderLayout.LINE_START, btn);
        frame.getContentPane().add(BorderLayout.CENTER, btn);
        //

        Dimension d = new Dimension(200, 100);
        frame.setSize(d);
        //frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        //frame.setLayout(new BorderLayout());
        //frame.pack();
        //frame.setLocationRelativeTo(null);
        frame.setVisible(true);
        //
    }

    private class AngelListener implements ActionListener {

        @Override
        public void actionPerformed(ActionEvent e) {
            System.out.println("-------------------华丽分割线----------------------");
        }
    }

    private class DevilListener implements ActionListener {

        @Override
        public void actionPerformed(ActionEvent e) {
            System.out.println("-------------------另外で一条，华丽の分割线----------------------");
        }
    }
}
